package com.pay.game.central.web.mapper;

import com.pay.game.central.web.bean.OrderStatistic;
import com.pay.game.central.web.bean.PayStatistic;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface StatisticMapper {

    @Insert("insert into pdd_order_statistic(goods_id,store_id,user_id,`date`,`datetime`) " +
            "values(#{goods_id},#{store_id},#{user_id},#{date,jdbcType=DATE},#{datetime,jdbcType=INTEGER})")
    void insertOrderStatistic(OrderStatistic orderStatistic);

    @Insert("insert into pdd_pay_statistic(goods_id,store_id,user_id,`date`,`datetime`) " +
            "values(#{goods_id},#{store_id},#{user_id},#{date,jdbcType=DATE},#{datetime,jdbcType=INTEGER})")
    void insertPayStatistic(PayStatistic payStatistic);

    @Select("select count(id) from pdd_order_statistic where user_id=#{userId} and `date`=#{date}")
    int countTodayOrderByUserId(@Param("userId") String userId, @Param("date") String date);

    @Select("select count(id) from pdd_pay_statistic where user_id=#{userId} and `date`=#{date}")
    int countTodayPayByUserId(@Param("userId") String userId, @Param("date") String date);

}
